package com.example.petcare.controller.user;


import com.example.petcare.pojo.Pet;
import com.example.petcare.pojo.Result;
import com.example.petcare.pojo.Review;
import com.example.petcare.service.ReviewService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController//标记为控制器类,并且返回json数据
@RequestMapping("/user/review")//请求路径
@Slf4j
public class ReviewController {

    @Autowired
    private ReviewService reviewService;

    // 添加评论
    @PostMapping("/add")
    public Result addReview(@RequestBody Review review) {
        reviewService.addReview(review);
        return Result.success();
    }

    // 根据providerId查询评论，列表
    @GetMapping("/get")
    public Result<List<Review>> listReview(@RequestParam Integer providerId) {
        List<Review> reviews = reviewService.list(providerId);

        return Result.success(reviews);
    }


}
